<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * SimplyPost
 *
 * @author		Pascal Kriete
 * @package		SimplyPost
 * @copyright	Copyright (c) 2008, Pascal Kriete
 * @license 	http://www.gnu.org/licenses/lgpl.txt
 */

// ------------------------------------------------------------------------

/**
 * Category Controller
 *
 * @package		SimplyPost
 * @subpackage	Category
 * @category	Controller
 * @author		Pascal Kriete
 */

class Category extends BaseController {

	/**
	 * Constructor
	 *
	 * @access	public
	 */
	function Category()
	{
		parent::BaseController();
	}
	
	// --------------------------------------------------------------------
	
	/**
	 * No category specified, throw error and redirect
	 *
	 * @access	public
	 */
	function index()
	{
		$this->session->set_flashdata('msg', $this->lang->line('cat_not_exist'));
		redirect('/');
	}
	
	// --------------------------------------------------------------------

	/**
	 * Show category and subforums
	 *
	 * @access	public
	 * @param	integer	category id
	 */
	function view($id = -1)
	{
		if ($id == -1)
		{
			$this->session->set_flashdata('msg', $this->lang->line('cat_not_exist'));
			redirect('/');
		}
		$this->breadcrumb->from_db($id, 'category');
		
		$this->load->helper('date');
		
		/* Load the model and get relevant category info */
		$this->load->model('forum/For_model', 'Forum');
		$cat_info = $this->Forum->get_info($id);
		
		$data['info'] = $cat_info[0];
		
		set_title(ucfirst($cat_info[0]['name']));

		$this->load->view('list', $data);
	}
}